const path = require("path");

// .jsx  .tsxß
module.exports = {
  mode: "development",
  entry: "./src/index.tsx",
  output: {
    // 输出到dist
    path: path.join(__dirname, "./dist"),
    filename: "bundle.js",
  },
  // import  from "xxxx.js" 省略后缀
  resolve: {
    extensions: [".js", ".ts", ".d.ts", ".jsx", ".tsx", ".css", ".json"],
  },
  module: {
    // 模块
    rules: [
      // 规则
      {
        test: /.(js|ts|jsx|tsx)?$/,
        loader: "babel-loader",
        options: {
          presets: [
            "@babel/preset-env",
            "@babel/preset-react",
            "@babel/preset-typescript",
          ],
        },
      },
      {
        test: /.css?$/,
        use: ["style-loader", "css-loader"],
      },
    ],
  },
};
